package main

import (
	"fmt"
)

//十进制转十六进制
func toHex(ten int) []string {
	m := 0
	hex := make([]int, 0)
	for {
		m = ten % 16
		ten = ten / 16
		if ten == 0 {
			hex = append(hex, m)
			break
		}
		hex = append(hex, m)
	}
	var hexStr []string
	for i := len(hex) - 1; i >= 0; i-- {
		if hex[i] >= 10 {
			hexStr = append(hexStr, fmt.Sprintf("%c", 'A'+hex[i]-10))
		} else {
			hexStr = append(hexStr, fmt.Sprintf("%d", hex[i]))
		}
	}
	return hexStr
	//return strings.Join(hexStr, "")
}

func main() {
	msgHex := toHex(16161616)
	fmt.Println(msgHex)
}
